
// house_pkg/pages/room/index.ts
Page({

  /**
   * 页面的初始数据
   */
  data: {
    
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(e) {
    //获取某个小区的名字和楼栋号
    this.setData({
      Apartment:e.Apartment,
      house:e.house
    })
    this.createRoom()
  },

  //生成楼号里面的随机房间,规则:一层楼最多四户,一共6-14层
  createRoom(){
    //房间号数组
    const roomList = []
    //生成随机楼层
    const floor = Math.floor(Math.random()*9+6)

    //遍历楼层
    for (let index = 1; index <= floor; index++) {
      //保存当前楼层
      const nowFloor = index
      //生成房间号
      for (let index = 1; index <= 4; index++) {
        //给数组添加当前楼层和房间号
        roomList.push(`${nowFloor}0${index}`)
      }
    }
    this.setData({
      roomList
    })
    // console.log(this.data.roomList);
  },
  //点击跳转到添加房屋
  goForm(e){
    //  /house_pkg/pages/form/index
    const { Apartment,house } = this.data
    wx.navigateTo({
      url: `/house_pkg/pages/form/index?point=${Apartment}&building=${house}&room=${e.mark.room}`,
    })
  }
})